<?php
/*
 * 
http://www.xunsearch.com/scws/download.php

/**
 * 分词
 * 
 * @param string/array $word
 * @return array
 */
function f_str_cutword($word){
	import("Flan.word.PSCWS4");
	$pscws = new \PSCWS4();
		
	$pscws->set_dict(LIB_PATH.'/Flan/word/scws/dict.utf8.xdb');
	$pscws->set_rule(APP_PATH.'/Flan/word/scws/rules.utf8.ini');
	$pscws->set_ignore(true);
	
	if (!is_array($word)){
		$pscws->send_text($word);
		$words = $pscws->get_tops(5);
		$tags = array();
		foreach ($words as $val) {
			$tags[] = $val['word'];
		}
		return $tags;
	} else {
		$aTags = array();
		$aWord = $word;
		foreach ($aWord as $word){
			$pscws->send_text($word);
			$words = $pscws->get_tops(5);
			$tags = array();
			foreach ($words as $val) {
				$tags[] = $val['word'];
			}
			$aTags[] = $tags;
		}
		return $aTags;
	}
	$pscws->close();
}